package com.landking.home.pic.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.landking.R;
import com.landking.db.table.LK_PIC_M;
import com.landking.home.pic.domain.PicStc;
import com.landking.http.HttpValues;
import com.landking.utils.PrefUtils;

import java.util.List;


/**
 * Created by 1013369768 on 2017/5/27.
 */

public class PicnameAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater mInflater;
    private List<LK_PIC_M> mUrList;
    private String http_ip;

    private static final RequestOptions BANNER_OPTIONS = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .dontAnimate()
            // .fitCenter()
            .centerCrop()
            .placeholder(R.drawable.ic_launcher);

    public PicnameAdapter(Context context, List<LK_PIC_M> urList) {
        this.context = context;
        this.mUrList = urList;
        this.mInflater = LayoutInflater.from(context);
        http_ip = PrefUtils.getString(context, HttpValues.HTTP_IP, HttpValues.HTTP_IP_BASE);
    }

    @Override
    public int getCount() {
        return mUrList.size();
    }

    @Override
    public Object getItem(int position) {
        return mUrList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_alert_list, null);
            holder.itemTv = (TextView) convertView.findViewById(R.id.tv_text1);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        LK_PIC_M item = mUrList.get(position);

        holder.itemTv.setText(item.getPictitle());
        return convertView;
    }

    private static class ViewHolder {
        public TextView itemTv;
    }
}
